package com.bwie.controller;

import com.bwie.pojo.Result;
import com.bwie.pojo.po.User;
import com.bwie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("user")
public class UserController {
    @RequestMapping("tologin")
    public String tologin(){
        return "login";
    }

    @Autowired
    public UserService userService;

    @GetMapping("login")
    @ResponseBody
    public Result login( User user) throws Exception {
        return userService.login(user);
    }

    @GetMapping("sendCode")
    @ResponseBody
    public Result  sendCode(String tel){
        return userService.sendCode(tel);
    }

    @GetMapping("sendLogin")
    @ResponseBody
    public Result sendLogin(@RequestBody User user){
        return userService.sendLogin(user);
    }
}
